package geon.utils;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;

public class DataUtils {

	public static Date formatData(String sData) {
		try {
			DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
			Date data = df.parse(sData);

			return data;

		} catch (ParseException e) {
			Logger.getLogger(DataUtils.class.getName()).log(Level.SEVERE, null, e);
		}
		return null;
	}

	public static String dataFormat(String sFormat) {

		Date data = Calendar.getInstance().getTime();

		DateFormat df = new SimpleDateFormat(sFormat);
		String sData = df.format(data);

		return sData;
	}

	public static String dataFormat(Date data, String sFormat) {

		DateFormat df = new SimpleDateFormat(sFormat);
		String sData = df.format(data);

		return sData;
	}
}
